<?php
namespace app\admin\controller;

use think\Controller;
use think\facade\Env;
use think\Request;
use app\admin\model\Admin as AdminModel;
use app\admin\model\Ncjy as NcjyModel;
use app\admin\model\Pic as PicModel;

class Index extends Controller
{
    public function index()
    {
        $adminCount = AdminModel::where('admin_role', '>', 100)->count();
        $ncjyCount = NcjyModel::count();
        $picCount = PicModel::count();

        $this->assign('adminCount',$adminCount);
        $this->assign('ncjyCount',$ncjyCount);
        $this->assign('picCount',$picCount);
        return $this->fetch();
    }

//    public function upload(Request $request)
//    {
//        $imgPath = '';
//        if($request->isPost()){
//            $file = $request->file('img');
//            // 上传文件验证
//            $result = $this->validate(['file' => $file], ['file'=>'require|image'],['file.require' => '请选择上传文件', 'file.image' => '非法图像文件']);
//            if(true !== $result){
//                $this->error($result);
//            }
//            //移动到框架应用根目录/public/uploads/目录下
//            //$info = $file->validate(['ext' => 'jpg,png'])->move(Env::get('root_path') . 'public' . '/' . 'uploads');
//            $info = $file->rule('date')->move(Env::get('root_path') . 'public' . '/' . 'uploads');
//            if($info){
//                //$this->success('文件上传成功：' . $info->getRealPath());
//                $imgPath ='/uploads/' . $info->getSaveName();
//            }else{
//                //上传失败获取错误信息
//                $this->error($file->getError());
//            }
//        }
//
//        $this->assign('imgPath', $imgPath);
//        return $this->fetch();
//    }
}
